/*
 * class for templating weapons
 */

package item.weapon;

import item.Item;

import java.io.Serializable;
import java.util.Comparator;

public class Weapon extends Item implements Serializable, Comparable<Weapon> {

	private static final long serialVersionUID = 3721698474502673594L; 
	
	public DamageType type; //what kind of weapon this is
	public int damage; //how much damage the weapon deals
	public int numAttacks; //how many times the weapon fires
	public int hitRate; //percentage hit chance per shot
	public int range; //how far the weapon can fire
	public int actionPoint; //how many points it takes to fire the weapon;
	
	//creates a Weapon object

	public Weapon(int cost, int condition, int level, int weight, DamageType type, int damage, int numAttacks, int hitRate, int range, int actionPoint) {
		super(cost, condition, level, weight);
		this.type = type;
		this.damage = damage;
		this.numAttacks = numAttacks;
		this.hitRate = hitRate;
		this.range = range;
		this.actionPoint = actionPoint;
	}//end of constructor with parameters Weapon
	
	public String toString() {
		return super.toString() + ": " + damage + ", " + numAttacks + ", " + hitRate + ", " + actionPoint + ", " + type.nameNomenclature;
	}
	
	//natural ordering by damage
	
	public int compareTo(Weapon w) {
		return w.damage - this.damage;
	}//end of method compareTo
	
	//creates a comparator based on damage
	
	public Comparator<Weapon> typeComparator() {
		return new Comparator<Weapon>() {
			public int compare(Weapon one, Weapon two) {
				return one.type.ordinal()-two.type.ordinal();
			}//end of method compare
		};//end of anonymous inner class
	}//end of method Comparator
	
}//end of class Weapon
